<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Index_Brand extends Controller_Index_Base
{ 
    public function action_index()
    {          
        $content = new View('index/brand/index_tpl');
        $letters = ORM::factory('brand')->get_first_letters();
        $brands  = ORM::factory('brand')->get_top_brands(array_keys($letters));
        $content->letters = $letters;
        $content->brands  = $brands;
        
        $this->print_template('Популярные бренды', $content);
    }
    
    public function action_letter()
    {
        $letter = $this->request->param('letter') ? mb_strtoupper($this->request->param('letter')) : null;
        
        $content = new View('index/brand/letter_tpl');
        $brands  = ORM::factory('brand')->get_brands_by_letter($letter);
        $content->letters = ORM::factory('brand')->get_first_letters();
        $content->letter  = $letter;
        $content->brands  = $brands;
        
        $this->print_template('Бренды на букву '.$letter, $content);
    }
} 
